import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/components/button/gf_button.dart';
import 'package:getwidget/components/rating/gf_rating.dart';
import 'package:getwidget/types/gf_button_type.dart';

import '../controllers/gfrating_controller.dart';

class GfratingView extends GetView<GfratingController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('五星评价'),
        centerTitle: true,
      ),
      body: Container(
        child: ListView(
          children: [
            Obx(() {
              return GFRating(
                value: controller.rating.value,
                onChanged: (value) {
                  controller.rating.value = value;
                },
              );
            }),

            Obx(() {
              return GFRating(
                value: controller.rating.value,
                onChanged: (value) {
                  controller.rating.value = value;
                },
                showTextForm: true,
                controller: controller.ratingController,
                suffixIcon: GFButton(
                  type: GFButtonType.transparent,
                  onPressed: () {
                    controller.rating.value = double.parse(controller.ratingController.text);
                  },
                  child: const Text('Rate'),
                ),
              );
            })
            
          ],
        ),
      ),
    );
  }
}
